package com.city.service.party.impl;

import com.city.domain.party.PartyMembership;
import com.city.repository.party.PartyMembershipRepository;
import com.city.service.party.PartyMembershipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PartyMembershipServiceImpl implements PartyMembershipService {

    @Autowired
    private PartyMembershipRepository partyMembershipRepository;

    @Override
    public void save(PartyMembership partyMembership) {
        partyMembershipRepository.save(partyMembership);
    }

    @Override
    public List<PartyMembership> findLimit(Integer page, Integer limit) {
        return partyMembershipRepository.findAllByPage((page-1)*limit,limit);
    }

    @Override
    public long count() {
        return partyMembershipRepository.count();
    }

    @Override
    public PartyMembership findById(int id) {
        return partyMembershipRepository.findOne(id);
    }

    @Override
    public void deleteById(int id) {
        partyMembershipRepository.delete(id);
    }

    @Override
    public List<PartyMembership> findLikeName(String name, Integer page, Integer limit) {
        return partyMembershipRepository.findAllByNameAndPage(name,(page-1)*limit,limit);
    }

    @Override
    public long countName(String name) {
        return partyMembershipRepository.countName(name);
    }

//    @Override
//    public PartyMembership findByUserId(int id) {
//        return partyMembershipRepository.findByUserID(id);
//    }
}
